
function obj2arr(o) 
{
    var a = [];
    for (var i in o) {
        if (o.hasOwnProperty(i)) {
            a.push(o[i]);
        }
    }
    return a;
}

function validateEmail(txt)
{
   var pattern =/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
   return pattern.test(txt);  // returns a boolean
}

function toTitleCase(str)
{
    return str.replace(/\w\S*/g, function(txt){
        return txt.charAt(0).toUpperCase() + 
                txt.substr(1).toLowerCase();});
}

var loading;
$(document).bind("ajaxSend", function() {
    window.clearTimeout(loading);
    loading = null;
    loading = window.setTimeout(function () {
        $('#spinx').show();
    }, 
    500);
//    $("#spinx").show();
}).bind("ajaxComplete", function() {
    window.clearTimeout(loading);
    $("#spinx").hide();
});
